package io;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;

public class OOSDemo {//对象序列化,即把对象转为字节
    public static void main(String[] args) throws IOException {
         String name ="张三";
         int age = 24;
         String gender ="男";
         String[] otherInfo={"是一名剑修","云居山山主","修为大乘期圆满"};
         Student zs =new Student(name,age,gender,otherInfo);

        FileOutputStream fos =new FileOutputStream("student.obj");//文件流
        ObjectOutputStream oos =new ObjectOutputStream(fos);//对象流
        oos.writeObject(zs);
        System.out.println(zs);//toString可以在print()中自动调用
        System.out.println("写出完毕");
        oos.close();

    }
}
